<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>北京联合大学</title>
</head>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- <link rel="stylesheet" href="https://at.alicdn.com/t/font_835526_xufba1hg66.css"> -->
<link rel="stylesheet" href="https://at.alicdn.com/t/font_835526_uzbxo9d25is.css">
<link rel="stylesheet" href="../../css/Initialization.css">
<link rel="stylesheet" href="../../css/commen.css">
<link rel="stylesheet" href="../../css/UploadResults.css">
<body>
<div id="content">
    <div class="initer">
        <!-- 具体内容 -->
        <div class="bread">
            <div class="plain">管理配置</div>
            <div class="plain">
                <i class="iconfont icon-right"></i>
            </div>
            <div class="plain current" >教师信息管理</div>
            <div class="center-button" id="importTeacherInfo">Excel导入教师信息</div>
        </div>
        <div class="teacherlookwork teacherlookteam teacherHuiZong">
            <table class="table">
                <tr class="tabletitle">
                    <td>ID</td>
                    <td>登录用户名</td>
                    <td>姓名</td>
                    <td>性别</td>
                    <!--td>负责模块</td-->
                    <td>操作</td>
                </tr>
                <tr th:each="item,itemStr : ${personList}">
                    <td th:text="${itemStr.count}">ID</td>
                    <td th:text="${item.username}">登录用户名</td>
                    <td th:text="${item.realname}">姓名</td>
                    <td th:if="${item.sex == 0}">男</td>
                    <td th:if="${item.sex == 1}">女</td>
                    <!--td th:text="${item.departname}">负责模块</td-->
                    <td>
                        <a href="javascript:void(0)" id="update" th:onclick="'javascript:repass(\''+${item.id}+'\')'" style="color:#23527c">重置密码</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                        <a href="javascript:void(0)" id="delete" th:onclick="'javascript:isdelete(\''+${item.id}+'\')'" style="color:#23527c">删除</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <!-- 确认弹框 -->
    <div class="teacherlookteammask none">
        <div class="fileinput">
            <div class="title">导入教师信息</div>
            <div class="tiptitle" onclick="download()">
                下载数据单元模板
            </div>
            <div class="tip">
                说明：请下载数据模板并按照模板内容填写的数据后再上传导入
            </div>
            <div class="optionsbuttons">
                <div class="center-button file">选择文件
                    <input type="file" name='file' id="file">
                </div>
                <div class="center-button cancel" id="importCancel">
                    取消导入
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../../js/jquery-3.4.1.min.js"></script>
<script src="../../js/commen.js"></script>
<script>
    function download() {
        location.href = "/files/models/teachermodel.xls";
    }
    function isdelete(id){
        $.ajax({
            type : "POST",
            url : "deletePerson",
            data : {id:id},
            dataType : "json",
            success : function(json) {
                if(json.state == success){
                    alert(json.result);
                    location.reload();
                }else{
                    alert(json.result);
                }
            },
            error:function(msg){
                alert("程序出错，请联系管理员");
            }
        });
    }

    function repass(id){
        $.ajax({
            type : "POST",
            url : "repass",
            data : {id:id},
            dataType : "json",
            success : function(json) {
                alert(json.result);
                if(json.state == success){
                    location.reload();
                }
            },
            error:function(msg){
                alert("程序出错，请联系管理员");
            }
        });
    }

    $(function () {
        $("#importTeacherInfo").click(function () {
            $('.teacherlookteammask').removeClass('none');
        });

        $("#importCancel").click(function () {
            $('.teacherlookteammask').addClass('none');
        })

        $("#file").change(function () {
            if($(this).val() != ""){
                var formData = new FormData();
                formData.append("file", document.getElementById("file").files[0]);
                $.ajax({
                    url: "upTeacherInfo",
                    type: "POST",
                    data: formData,
                    contentType: false,
                    processData: false,
                    dataType:"json",
                    success: function (data) {
                        if(data.state == success){
                            alert("上传成功");
                            location.reload();
                        }else if(data.state == error){
                            alert(data.result);
                        }
                    },
                    error: function () {
                        alert("上传失败！");
                    }
                });
            }
        })
    })
</script>
</body>
</html>

